package com.gzy.net_app.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import com.gzy.net_app.application.AppContext;
import com.gzy.net_app.databinding.ActivitySettingBinding;
import com.gzy.net_app.ui.BaseActivity;
import com.orhanobut.hawk.Hawk;

public class SettingActivity extends BaseActivity<ActivitySettingBinding> {

  public static final String TAG = SettingActivity.class.getSimpleName();

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    initData();
  }

  private void initData() {
    binding.exitUser.setOnClickListener(view -> LogoutUser());

    binding.settingReturn.setOnClickListener(view -> finish());

    binding.updateInfo.setOnClickListener(view -> AppContext.showToast("修改信息，暂未开发"));
  }

  private void LogoutUser() {

    // lyoutUser();
    Hawk.delete("token");
    Intent intent = new Intent(SettingActivity.this, LoginActivity.class);
    startActivity(intent);

    removeALLActivity();//执行移除所以Activity方法
    // finish();
  }

  //退出
  // private void lyoutUser() {
  //   String username = Hawk.get("username");
  //
  //   JSONObject jsonData = new JSONObject();
  //   try {
  //     jsonData.put("login", username);
  //   } catch (JSONException e) {
  //     e.printStackTrace();
  //   }
  //
  //   RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonData.toString());
  //
  //   NetworkApi.createService(ApiService.class)
  //       .layoutApi(requestBody)
  //       .compose(NetworkApi.applySchedulers(new BaseObserver<ResponseBody>() {
  //         @Override public void onSuccess(ResponseBody responseBody) {
  //           String result = AppContext.doJson(responseBody);
  //           AppContext.showToast(result);
  //           KLog.d(TAG, "退出成功");
  //         }
  //
  //         //获取验证码
  //         @Override public void onFailure(Throwable e) {
  //           KLog.e(TAG, e.getMessage());
  //         }
  //       }));
  // }

}